Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deflake run_kubectl_apply_tests #93657

Merged
merged 1 commit into from
Aug 5, 2020

Conversation

knight42
Copy link
Member

@knight42 knight42 commented Aug 3, 2020

Signed-off-by: knight42 anonymousknight96@gmail.com

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:

/kind api-change
/kind bug
/kind cleanup
/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind feature

/kind flake

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #93651

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/flake Categorizes issue or PR as related to a flaky test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Aug 3, 2020
@k8s-ci-robot k8s-ci-robot added area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 3, 2020
@@ -444,6 +444,9 @@ run_kubectl_server_side_apply_tests() {
}
__EOF__

# Ensure the CRD has been created
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the correct check... the CRD will always be created here

The issue is whether the API server has recognized and started serving the associated CR API yet

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liggitt Is it possible to do a wait on a Condition for a CRD? (e.g. kubectl wait --for=condition=Ready mygroup.example.com/myobj --timeout=30s)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to wait until kubectl observes the expected API available in discovery (kubectl api-resources contains the new API)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seans3 you could wait for condition Established, although I am not certain that guarantees that it is being served

Established CustomResourceDefinitionConditionType = "Established"

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 3, 2020
@knight42 knight42 requested a review from liggitt August 3, 2020 17:36
@knight42
Copy link
Member Author

knight42 commented Aug 4, 2020

/test pull-kubernetes-conformance-kind-ipv6-parallel

break
fi
echo "${i}: Waiting for CR API to be available"
sleep $((i-1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be missing something but why the changing sleep time? Is it intended to be a rudimentary backoff?

Copy link
Member Author

@knight42 knight42 Aug 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no special reason, just following the existing practice

for j in $(seq 1 "${tries}"); do
# shellcheck disable=SC2086
# Disabling because "args" needs to allow for expansion here
res=$(eval kubectl get "${kube_flags[@]}" ${args} "${object}" -o go-template=\""${request}"\")
if [[ "${res}" =~ ^$expected$ ]]; then
echo -n "${green}"
echo "$(kube::test::get_caller 3): Successful get ${object} ${request}: ${res}"
echo -n "${reset}"
return 0
fi
echo "Waiting for Get ${object} ${request} ${args}: expected: ${expected}, got: ${res}"
sleep $((j-1))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could fix the sleep time if that is preferred

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knight42 I think it's okay, just wanted to know the motivation :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is similar, used in other places, and is easier to read:

Suggested change
sleep $((i-1))
sleep "${i}"

@hasheddan
Copy link
Contributor

Saw another flake on this last night. @liggitt could you give this another look?

# Ensure the API server has recognized and started serving the associated CR API
local tries=5
for i in $(seq 1 $tries); do
if kubectl "${kube_flags_with_token[@]}" api-resources --api-group 'mygroup.example.com' -oname | grep -q 'resources.mygroup.example.com'; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

piping to grep -q breaks things, see #57805

# Ensure the API server has recognized and started serving the associated CR API
local tries=5
for i in $(seq 1 $tries); do
local output=$(kubectl "${kube_flags_with_token[@]}" api-resources --api-group 'mygroup.example.com' -oname)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local output=$(kubectl "${kube_flags_with_token[@]}" api-resources --api-group 'mygroup.example.com' -oname)
local output=$(kubectl "${kube_flags[@]}" api-resources --api-group mygroup.example.com -o name)

@liggitt
Copy link
Member

liggitt commented Aug 5, 2020

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 5, 2020
@liggitt
Copy link
Member

liggitt commented Aug 5, 2020

/milestone v1.19

test-only change addressing a flake clouding CI signal

@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Aug 5, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: knight42, liggitt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 5, 2020
Signed-off-by: knight42 <anonymousknight96@gmail.com>
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 5, 2020
@knight42
Copy link
Member Author

knight42 commented Aug 5, 2020

Force push to address shellcheck errors: https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/93657/pull-kubernetes-verify/1291016793187422209

Errors from shellcheck:

In ./test/cmd/apply.sh line 450:
      local output=$(kubectl "${kube_flags[@]:?}" api-resources --api-group mygroup.example.com -oname)
            ^----^ SC2155: Declare and assign separately to avoid masking return values.


In ./test/cmd/apply.sh line 455:
      sleep $i
            ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
      sleep "$i"

@liggitt
Copy link
Member

liggitt commented Aug 5, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 5, 2020
@k8s-ci-robot k8s-ci-robot merged commit c94242a into kubernetes:master Aug 5, 2020
@knight42 knight42 deleted the test/93651 branch August 5, 2020 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/flake Categorizes issue or PR as related to a flaky test. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Flaky Test] run_kubectl_apply_tests (ci-kubernetes-integration-master)
5 participants